package com.emep.changzhi.analyse.http.statistics;


import com.emep.changzhi.analyse.model.ResultBean;
import com.emep.changzhi.analyse.service.statistics.GetDayAqiService;
import com.emep.changzhi.analyse.service.statistics.PollutionAverageService;
import com.emep.changzhi.analyse.utils.Constant;
import com.emep.changzhi.analyse.utils.DataValidator;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("stat")
@Api(value="api统计服务",tags={"统计指定时间范围,指定站点,指定城市,污染物的平均值"})
public class PollutionAverageController {

    @Autowired
    private PollutionAverageService pollutionAverageService;


    @ApiOperation(value="根据时间站点城市查询污染物", notes="统计指定时间范围,指定站点,指定城市,污染物的平均值")
    @ApiResponses({ @ApiResponse(code = 1, message = "操作成功"),
            @ApiResponse(code = 0, message = "操作失败，服务器内部异常"),
            @ApiResponse(code = 303, message = "权限不足") })

    @GetMapping(value = "pollution/average")
    public ResultBean<Map<String,Object>> findapiByTime(@RequestParam Map<String, Object> payload){
        ResultBean result = DataValidator.validateMapData(payload);
        if (result.getCode() == Constant.RESULT_CODE_SUCCESS) {
            return  result.ok(pollutionAverageService.findapiByTime(payload));
        }

        return  result;
    }
}
